package com.cpe.data.domain.student.classproject;

import java.util.Date;
import java.util.Map;

import com.cpe.data.domain.classsproject.ClassProjectRef;
import com.cpe.data.domain.student.StudentRef;
import com.google.common.collect.Maps;
import com.sql.data.response.BaseInfo;

import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = false)
public class StudentClassProjectInfo extends BaseInfo {
	private static final long serialVersionUID = -4506125789557804805L;

	private StudentRef studentRef;

	private ClassProjectRef classProjectRef;

	private Date scoreDate;

	private Float score;

	private String unit;

	private String scoreDesc;

	public StudentClassProjectInfo scoreDesc(Float ltScorePercent) {
		if (ltScorePercent == null) {
			this.scoreDesc = SCORE_DESC.get(5);
			return this;
		}
		int level = (int) (ltScorePercent * 10);
		switch (level) {
		case 0:
		case 1:
		case 2:
		case 3:
		case 4:
		case 5:
			this.scoreDesc = SCORE_DESC.get(1);
			break;
		case 6:
		case 7:
			this.scoreDesc = SCORE_DESC.get(2);
			break;
		case 8:
			this.scoreDesc = SCORE_DESC.get(3);
			break;
		case 9:
			this.scoreDesc = SCORE_DESC.get(4);
			break;
		case 10:
		default:
			this.scoreDesc = SCORE_DESC.get(5);
			break;
		}
		return this;
	}

	private final static Map<Integer, String> SCORE_DESC;

	static {
		SCORE_DESC = Maps.newHashMap();
		SCORE_DESC.put(1, "加油！您的这项测试击败了60%的对手！还需要努力哦！");
		SCORE_DESC.put(2, "很不错！您的这项测试击败了60%-80%的对手！加油哦！");
		SCORE_DESC.put(3, "太棒了！您的这项测试击败了80%-90%的对手！");
		SCORE_DESC.put(4, "太厉害啦！您的这项测试击败了90%-99%的对手！祝贺您！");
		SCORE_DESC.put(5, "恭喜您！您的这项测试成绩是这个项目的最高成绩！");
	}
}
